#pragma once

#ifndef PLAYER_H
#define PLAYER_H

#include <list>
#include "Entity.h"
#include "EntityManager.h"
#include "Level.h"
#include "LevelManager.h"
#include "StateMachine.h"
#include "Collision.h"
#include "Contact.h"
#include "AnimationPlayer.h"
#include "Particle.h"
#include "ForceGenerator.h"
#include "ForceRegistry.h"
#include "Gravity.h"
#include "Drag.h"
#include "Rock.h"
#include "Melle.h"

class Player : public Entity
{
private:
	Level* level;
	AnimationPlayer* playerAnims;
	std::list<Rock*> rocks;
	std::list<Melle*> melle;
	float melleTimer;
	bool flip;
	bool climb;
	bool stunned;
	bool dead;
	float stunnedTimer;
	Particle particle;
	Gravity gravity;
	Drag drag;
public:
	Player(AnimationPlayer* playerAnims, Level* level)
		: Entity(level->getStartPoint(), 0, "Player"),
		level(level),
		playerAnims(playerAnims),
		particle(level->getStartPoint(), D3DXVECTOR3(0, 0, 0), 1000.0f),
		gravity(D3DXVECTOR3(0, 500.0f, 0)),
		drag(0.1f, 0.5f)
		
	{
		ForceRegistry::add(&particle, &gravity);
		ForceRegistry::add(&particle, &drag);
		playerAnims->playAnimation("Idle");
		texture = playerAnims->getCurrentAnimation()->getTexture();
		stunnedTimer = 0;
	}
	~Player() { delete playerAnims; }
	void update(float frameTime);
	void draw(ID3DXSprite* sprite);
	void handleMessage(Message message);
	// Getters and setters.
	void setLevel(Level* newLevel) { level = newLevel; }
	D3DXVECTOR3 getPosition() { return particle.position; }
	virtual void setPosition(D3DXVECTOR3 newPosition)
	{ 
		position = newPosition; 
		particle.position = newPosition;
	}
	IDirect3DTexture9* getTexture()
	{
		return texture;
	}
};

#endif